/*
 * A Data class that hold the datagram 
 * Written by YUE CHI
 */

import java.util.Collection;
import java.util.Collections;
import java.util.SortedSet;
import java.util.TreeSet;

/**
 * A Data class store the dataset of word.
 * @author YUE CHI
 * @version 1.0
 */
public class Data
{
  /** the current number of search word.**/
  private final int my_number;
  
  /** The word need to be searched.**/
  private final String my_word;
  
  /** if the word in the wordlist.**/
  private final boolean my_inlist;
  
  /** A set of suggestion word.**/
  private final SortedSet my_set = new TreeSet();

  /**
   * A dataset with the words.
   * @param the_i the current number of word
   * @param the_s the word
   * @param the_b if the word in the list
   * @param the_collection a treeset collection
   */
  public Data(final int the_i, 
              final String the_s, final boolean the_b, final Collection the_collection)
  {
    this.my_number = the_i;
    this.my_word = the_s;
    this.my_inlist = the_b;
    if (the_collection != null)
    {
      this.my_set.addAll(the_collection);
    }
  }

  /**
   * Get the current number.
   * @return the number.
   */
  public int getnumber()
  {
    return this.my_number;
  }

  /**
   * get the word.
   * @return the word is searched
   */
  public String getWord()
  {
    return this.my_word;
  }

  /**
   * If the word in the wordlist.
   * @return true if it is in the list.
   */
  public boolean isInlist()
  {
    return this.my_inlist;
  }

  /**
   * A sorted set of suggestion word in alphabetic order.
   * @return a suggestion word list
   */
  public SortedSet getSortedSet()
  {
    return Collections.unmodifiableSortedSet(this.my_set);
  }
}
